<?php
/**
 * Created by PhpStorm.
 * User: liuhong
 * Date: 2019-04-11
 * Time: 11:37
 */

namespace app\service;


use think\Db;
use think\Exception;

/**
 * 提现
 * Class WithdrawalService
 * @package app\service
 */
class WithdrawalService extends BaseService
{
   public $withdrawalModel;
   public function __construct()
   {
       $this->withdrawalModel=Db::name('withdrawal');
   }


    /**根据用户ID查询提现
     * @param $uid
     * @param $page
     * @param $page_num
     * @return array|bool
     */
   public function selectListByUid($uid,$page,$page_num){
       try{
           return $this->withdrawalModel
               ->where('uid',$uid)
               ->page($page,$page_num)
               ->select()
               ->toArray();
       }catch (Exception $ex){
           LogService::S()->writeLog('Exception',$ex->getMessage());
           return false;
       }
   }

    /**
     * @param $where
     * @return bool|int|string
     */
    public function countWithdrawal($where){
        try{
            return $this->withdrawalModel
                ->where($where)
               ->count();
        }catch (Exception $ex){
            LogService::S()->writeLog('Exception',$ex->getMessage());
            return false;
        }
    }

    /**\根据用户ID查询钱包
     * @param $uid
     * @return array|bool
     */
    public function selectListByWhere($where){
        try{
            return $this->withdrawalModel
                ->where($where)
                ->select()
                ->toArray();
        }catch (Exception $ex){
            LogService::S()->writeLog('Exception',$ex->getMessage());
            return false;
        }
    }

    /**
     * 添加申请提现列表
     * @param $add
     * @return bool|int|string
     */
    public function addList($add){
        try{
            return $this->withdrawalModel->insertGetId($add);
        }catch (Exception $ex){
            LogService::S()->writeLog('Exception',$ex->getMessage());
            return false;
        }
    }
}